import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class GameCard {
    public static final String[] suits = {"♣","♦","♠","♥"};
    List<Card> list = new ArrayList<>();
    //买牌
    public List<Card> BuyCard() {
        for (int i = 0; i < suits.length; i++) {
            for (int j = 1; j <= 13 ; j++) {
                Card card = new Card(suits[i],j);
                list.add(card);
            }
        }
        return list;
    }
    public void shuffle(List<Card> card) {
        Random random = new Random();
        for (int i = card.size() - 1; i > 0 ; i--) {
           int index = random.nextInt(13);
            swap(card,i,index);
        }
    }
    public static void swap(List<Card> card,int i,int j) {
        Card tmp = card.get(i);
        card.set(i,card.get(j));
        card.set(j,tmp);
}
//发牌
    public List<List<Card>> takeCard(List<Card> card) {
        List<List<Card>> hand =new ArrayList<>();
        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<Card> hand3 = new ArrayList<>();
        hand.add(hand1);
        hand.add(hand2);
        hand.add(hand3);
        for (int i = 0; i < 5; i++) {

            for (int j = 0; j < 3; j++) {
                Card tmp = card.remove(0);
                hand.get(j).add(tmp);
            }
        }

        return hand;
    }

}
